package com.windy.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.windy.api.product.ProductClient;
import com.windy.app.entity.Order;
import com.windy.app.entity.Product;
import com.windy.app.vo.Result;
import com.windy.mapper.OrderMapper;
import com.windy.service.IOrderService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("orderService")
@GlobalTransactional
public class OrderServiceImpl extends ServiceImpl<OrderMapper,Order> implements IOrderService {

    @Resource
    private ProductClient productClient;

    @Override
    public Result<Order> addOrder(Integer orderId) {
        Order order = new Order();
        order.setProId(Long.valueOf(1));
        order.setProName("aa");
        order.setProNum(2);
        order.setUnitAmount(10.0);
        order.setAmount(20.0);
        order.setState("1");
        int i = this.baseMapper.insert(order);
        productClient.kcc(order.getProId(), order.getProNum());
        return new Result<Order>(true,"增加成功！",order);
    }
}
